from langchain_community.document_loaders import JSONLoader
from langchain_community.embeddings import DashScopeEmbeddings
from langchain_community.vectorstores import Chroma
from langchain_text_splitters import CharacterTextSplitter

doc = JSONLoader(
    file_path="./data.json",
    jq_schema=".[].content  +  .[].answer",
    text_content=True,
)
charactor_splitter = CharacterTextSplitter('\n', chunk_size=100, chunk_overlap=0)
docx = charactor_splitter.split_documents(doc.load())
embeddings = DashScopeEmbeddings()
Chroma.from_documents(docx, embeddings, persist_directory="./database/chroma_db")

